<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets">


    <ui:composition template="../../resources/template/indexTemplate.xhtml">

        <ui:define name="ẗitle">-= Associacao - Lista de Usuários =-</ui:define>

        <ui:define name="content">

            <p:panel rendered="#{userMB.admin}"
                     tyleClass="content" style="background:none;">

                <!-- 			<p:panel rendered="{userMB.admin}" -->
                <!-- 			header="Cadastro de Associado {associadoMB.atualizaListaAssociadosTable()}" -->
                <!-- 			styleClass="content" style="background:none;"> -->

                <h:form id="formAssociadoCad">

                    <p:growl id="messages" />

                    <h:panelGrid columns="3">

                        <h:outputLabel for="nome" value="Nome*" />
                        <p:inputText id="nome"
                                     value="#{associadoMB.associado.nome}" size="40"
                                     required="true" requiredMessage="Campo Obrigatório">
                        </p:inputText>
                        <p:message for="nome" />


                        <h:outputLabel for="nascimento" value="Data de Nascimento*" />
                        <p:calendar id="nascimento" pattern="dd/MM/yyyy" navigator="true"
                                    value="#{associadoMB.associado.nascimento}"
                                    required="true" requiredMessage="Campo Obrigatório" size="40">
                        </p:calendar>
                        <p:message for="nascimento" />



                        <h:outputLabel for="sexo" value="Sexo: " />  
                        <p:selectOneMenu id="sexo" value="#{associadoMB.associado.sexo}" effect="fade" size="40">  
                            <f:selectItem itemLabel="Masculino" itemValue="m" />  
                            <f:selectItem itemLabel="Feminino" itemValue="f" />  
                        </p:selectOneMenu> 
                        <p:message for="sexo" />



                        <h:outputLabel for="rg" value="R.G." />
                        <p:inputText id="rg"
                                     value="#{associadoMB.associado.rg}" size="40" />
                        <p:message for="rg" />


                        <h:outputLabel for="uf_rg" value="UF do Rg: " />  
                        <p:selectOneMenu id="uf_rg" value="#{associadoMB.associado.ufRg}" effect="fade" >  
                            <f:selectItem itemLabel="Select One" itemValue="" />  
                            <f:selectItems value="#{associadoMB.ufs}" var="uf" itemLabel="#{uf.sigla}" itemValue="#{uf}"/>  
                        </p:selectOneMenu> 
                        <p:message for="uf_rg" />

                        <h:outputLabel for="cpf" value="CPF*" />
                        <p:inputText id="cpf"
                                     value="#{associadoMB.associado.cpf}" size="40"
                                     required="true" requiredMessage="Campo Obrigatório" />
                        <p:message for="cpf" />

                        <h:outputLabel for="passaporte" value="Número do Passaporte" />
                        <p:inputText id="passaporte"
                                     value="#{associadoMB.associado.passaporte}"
                                     size="40" />
                        <p:message for="passaporte" />


                        <h:outputLabel for="email" value="E-Mail*" />
                        <p:inputText id="email"
                                     value="#{associadoMB.associado.email}"
                                     size="40" required="true" requiredMessage="Campo Obrigatório" />
                        <p:message for="email" />


                        <!-- 					<h:outputLabel for="banco" value="Banco*" /> -->
                        <!-- 					<p:inputText id="banco" -->
                        <!-- 						value="||{associadoMB.associado.banco}" -->
                        <!-- 						size="20" required="true" requiredMessage="Campo Obrigatório" /> -->
                        <!-- 					<p:message for="banco" /> -->


                        <!-- 					<h:outputLabel for="agencia" value="Agência*" /> -->
                        <!-- 					<p:inputText id="agencia" -->
                        <!-- 						value="||{associadoMB.associado.agenciaBanco}" -->
                        <!-- 						size="20" required="true" requiredMessage="Campo Obrigatório" /> -->
                        <!-- 					<p:message for="agencia" /> -->

                        <!-- 					<h:outputLabel for="conta" value="Número da Conta*" /> -->
                        <!-- 					<p:inputText id="conta" -->
                        <!-- 						value="||{associadoMB.associado.contaBanco}" -->
                        <!-- 						size="20" required="true" requiredMessage="Campo Obrigatório" /> -->
                        <!-- 					<p:message for="conta" /> -->



                    </h:panelGrid>




                    <p:commandButton value="Telefone" 
                                     icon="ui-icon-plus" 
                                     update=":formAssociadoCad"
                                     actionListener="#{telefoneMB.reset()}" 
                                     onclick="telefoneCreateDialog.show();" />




                    
                    <p:dataTable  id="tabelaTelefone" widgetVar="tabela" var="tda" 
                                  value="#{associadoMB.associado.telefoneDoAssociados}" 
                                  emptyMessage="Não há telefones cadastrados." 
                                  style="width: 500px"
                                  rowIndexVar="rowIndex"
                                  >
                        <p:column 
                            headerText="Número"
                            
                            >
                            <h:outputText value="#{rowIndex}" />          
                        </p:column>
                      

                        <p:column 
                            headerText="Telefone"
                                                        >
                            <h:outputText value="#{tda.telefone.telefone}" />          
                        </p:column>

                        <p:column 
                            headerText="Tipo" 
                            >
                            <h:outputText value="#{tda.telefone.tipoTelefone.tipo}"  />          
                        </p:column>

                        <p:column >
                            <p:commandButton id="botaoEditarTelefone" image="ui-icon ui-icon-pencil" title="Editar"  action="#{associadoMB.prepararAlterarTelefone(tda)}" onclick="telefoneCreateDialog.show();"  />
                            <p:commandButton id="botaoDeletarTelefone" image="ui-icon ui-icon-close" title="Remover" actionListener="#{associadoMB.removeTelefone(tda)}" update=":formAssociadoCad"/>
                        </p:column>  
                    </p:dataTable>













                    <h:panelGrid columns="2">
                        <p:commandButton id="botaoSalvar" type="submit" value="Salvar"
                                         action="#{associadoMB.persiste()}" ajax="false" />
                        <p:commandButton id="botaoCancelar" type="submit" value="Cancelar"
                                         ajax="false" immediate="true"
                                         action="#{associadoMB.reset}" />
                    </h:panelGrid>


                </h:form>
            </p:panel>

            <ui:include src="/pages/protected/telefone/telefoneCreateDialog.xhtml" />

        </ui:define>
    </ui:composition>
</html>

